package com.han.walkman.service.impl;

import com.han.walkman.dao.DocumentDao;
import com.han.walkman.entity.DocumentEntity;
import com.han.walkman.service.DocumentService;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author: Hanjiafeng
 * @Date: 2020/5/7
 * @Desc:
 */
@Service
public class DocumentServiceImpl implements DocumentService {
    private final DocumentDao documentDao;

    public DocumentServiceImpl(DocumentDao documentDao) {
        this.documentDao = documentDao;
    }

    @Override
    public void add(DocumentEntity documentEntity) {
        documentDao.save(documentEntity);
    }

    @Override
    public void delete(DocumentEntity documentEntity) {
        documentDao.delete(documentEntity);
    }

    @Override
    public void update(DocumentEntity documentEntity) {
        documentDao.save(documentEntity);
    }

    @Override
    public List<DocumentEntity> findAll() {
        return documentDao.findAll();
    }

    @Override
    public Page<DocumentEntity> findAll(Pageable pageable) {
        return documentDao.findAll(pageable);
    }

    @Override
    public List<DocumentEntity> findAll(Example<DocumentEntity> entityExample) {
        return documentDao.findAll(entityExample);
    }

    @Override
    public Page<DocumentEntity> findAll(Example<DocumentEntity> entityExample, Pageable pageable) {
        return documentDao.findAll(entityExample, pageable);
    }

    @Override
    public Optional<DocumentEntity> findById(Integer id) {
        return documentDao.findById(id);
    }
}
